import Vue from "vue";
import VueRouter from "vue-router";
import routes from "./routes";
import { setTitle } from "@/utils";

//有window.VueRouter说明是传统引用（cdn）,没有则代表是第三方库引用
if (!window.VueRouter) {
	Vue.use(VueRouter); //使用一个vue插件
}

const router = new VueRouter({
	routes, //路由配置规则
	mode: "history",
});

//跳转之后进行判断
router.afterEach((to, from) => {
	if (to.meta.title) {
		setTitle.setrouterTitle(to.meta.title);
	}
});

export default router;
